// 弹出taost消息
const toast = function (msg) {
    wx.showToast({
        title: msg,
        icon: 'none',
        duration: 2000
    })
}
// 获取缓存
const get = function (name) {
    return wx.getStorageSync(name);
}
// 存入缓存
const set = function (name, value) {
    wx.setStorageSync(name, value);
}

// loading效果
const show = function () {
    wx.showLoading({
        title: '加载中',
    });
}

// 隐藏loading
const hide = function () {
    wx.hideLoading();
}

// 模态框
const modal = function (title, content) {
    return new Promise((resolve, reject) => {
        wx.showModal({
            title,
            content,
            success(res) {
                resolve(res);
            },
            fail: function (error) {
                reject(error);
            }
        })
    })
}

// 页面跳转
const go = function (url) {
    wx.navigateTo({ url });
}


module.exports = {
    toast,
    get,
    set,
    show,
    hide,
    modal,
    go
}